Repository navigation
Marshal Windows DropTarget registration to window thread and throttle DragOver - #102
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the Windows drag-source (
explorer.exe) freeze and hover stutter reported in libnativeapi/nativeapi#57:DropTargetregistration/revocation onto the window's owning Win32 thread (src/platform/windows/drop_target_windows.cpp):UIThreadPolicy::RunOnSeparateThread,DropTarget::AddListener()runs on the Dart UI isolate thread, which has no Win32 message loop. CallingOleInitialize+RegisterDragDropthere placedDropTargetComin an unpumped STA apartment, so OLE's cross-apartmentDragEnterRPC fromexplorer.exedeadlocked forever.detail::PostToThread(RunOnOwningThread) to runOleInitialize,DropTargetComcreation,RegisterDragDrop, and teardown (RevokeDragDrop/Release/OleUninitialize) onhwnd's owning Win32 thread, with an atomicaliveguard.RegisterDragDropreturnsDRAGDROP_E_ALREADYREGISTERED, callRevokeDragDropand retry once.IDropTargetHelpercalls & throttleDragOver:helper_active_soDragOver/DragLeave/Droponly callIDropTargetHelperafter a successfulhelper_->DragEnter(...); skip redundanthelper_->DragOvercalls when position and effect are unchanged.DragEnterand throttleDropTargetMovedEventemission to ~60 Hz (16 ms) while still returning the exactDROPEFFECTimmediately on everyDragOver.tests/drop_target_ui_thread_windows_test.cpp):DropTargetfrom a non-pumping isolate thread and invokingDragEnter/DragOver/DragLeavefrom a third STA thread completes without freezing, runs callbacks on the platform thread, and revokes cleanly on destruction.Related to libnativeapi/nativeapi#57.
Verification
drop_target_ui_thread_windows_test: Passed on Windows (built cleanly on top oforigin/main).RunOnSeparateThreadapp dragging files from Explorer:explorer.exeno longer freezes and hover/drop events update smoothly.